<?php
namespace app\saas\middleware;

// 全局中间件 try catch 捕获异常
class CheckException
{
    public function handle($request, \Closure $next)
    {
        /*--- start 跨域用 ---*/
        header('Access-Control-Allow-Origin: *');                                    // 允许任意域名发起的跨域请求
        header('Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE');
        header('Access-Control-Allow-Headers: X-Requested-With,X_Requested_With,x_requested_with,x-requested-with,content-type');
        /*--- end 跨域用---*/

        request()->mallData = ["id" => 0]; // SaaS端设置0，跟商城区分开
        return $next($request);
    }
}
